package com.kaer.plugin.utils;

import android.os.Environment;

import java.io.File;

/**
 * Created by jxz on 2016/10/14.
 */

public class SdCardUtils {
    // 项目文件根目录
    public static final String FILEDIR = "/attendance";
    // 照相机照片目录
    public static final String FILEIMAGE = "/images";
    // 拍摄视频存放
    public static final String FILEVIDEO = "/videos";
    // 应用程序缓存
    public static final String FILECACHE = "/cache";
    // 用户信息目录
    public static final String FILEUSER = "/user";
    //本地通知目录
    public static final String FILENOTICE = "/notice";
    //本地通告
    public static final String USERNOTICE = "/user";
    //平台通告
    public static final String TERMINALNOTICE = "/terminal";//20161111_jinxiuzhen add terminal notice component.
    //
    public static final String FILEPHOTOS = "/photos";
    //语音合成
    public static final String FILEVOICE = "/voice";

    /*
     * 检查sd卡是否可用
     * getExternalStorageState 获取状态
     * Environment.MEDIA_MOUNTED 直译  环境媒体登上  表示，当前sd可用
     */
    public static boolean checkSdCard() {
        if (Environment.getExternalStorageState().equals(
                Environment.MEDIA_MOUNTED))
            //sd卡可用
            return true;
        else
            //当前sd卡不可用
            return false;
    }

    /*
     * 获取sd卡的文件路径
          * getExternalStorageDirectory 获取路径
     */
    public static String getSdPath() {
        return Environment.getExternalStorageDirectory() + "";
    }

    /*
     * 创建一个文件夹
     */
    public static void createFileDir(String fileDir) {
        String path = getSdPath() + fileDir;
        File path1 = new File(path);
        if (!path1.exists()) {
            path1.mkdirs();
        }
    }

    public static String getImagePath() {
        return getSdPath() + FILEDIR + FILEIMAGE;
    }

    public static String getVideoPath() {
        return getSdPath() + FILEDIR + FILEVIDEO;
    }

    public static String getLocalNoticePath() {
        return getSdPath() + FILEDIR + FILENOTICE + USERNOTICE;
    }
    //20161111_jinxiuzhen add terminal notice component.[S]
    public static String getTerminalNoticePath() {
        return getSdPath() + FILEDIR + FILENOTICE + TERMINALNOTICE;
    }
    //20161111_jinxiuzhen add terminal notice component.[E]

    public static String getUserPath() {
        return getSdPath() + FILEDIR + FILEUSER;
    }

    public static String getPhotosPath() {
        return getSdPath() + FILEDIR + FILEPHOTOS;
    }

    public static String getVoicePath() {
        return getSdPath() + FILEDIR + FILEVOICE;
    }

}
